﻿package fwk.form.elements 
{
	import flash.display.MovieClip;
	import flash.events.FocusEvent;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.MouseEvent;
	
	public class ReponseRadioCheck extends AbstractReponse
	{
		
		
		
		public function ReponseRadioCheck(mc:MovieClip = null)
		{
			super(mc);
			

			mc.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
			mc.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
			
		}
		private function onFocusIn(e:FocusEvent):void 
		{
			dispatchEvent( new FocusEvent( FocusEvent.FOCUS_IN));
			
			if (shapeFocus) {
				spriteFocus.graphics.clear();
				spriteFocus.graphics.beginFill(colorShapeFocus, 0.2);
				spriteFocus.graphics.drawRect( mc.box.x - 3,  mc.box.y - 3, mc.box.width + 6, mc.box.height + 6);
				mc.addChildAt(spriteFocus, 0);
			}
			
			
		}
		private function onFocusOut(e:FocusEvent):void 
		{
			dispatchEvent( new FocusEvent( FocusEvent.FOCUS_OUT));
			if (shapeFocus) mc.removeChild(spriteFocus);
		}
		
		
		override public function set tabIndex(value:int):void 
		{
			if (value == -1) {
				mc.tabEnabled = false;
			}else {
				mc.tabEnabled = true;
			}
			
			mc.tabIndex = value;
		}
		
		

		override public function onMouseOut(e:MouseEvent):void 
		{
			if ( hasLabel("out", mc.box) && mc.box.currentLabel != "out")
			{
				mc.box.gotoAndPlay("out");
			}
		}
		
		override public function onMouseOver(e:MouseEvent):void 
		{
			if ( hasLabel("over", mc.box) &&  mc.box.currentLabel != "over")
			{
				mc.box.gotoAndPlay("over");
			}
		}

		
		
	}
	
}